package io.renren.api.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.api.dao.BtNavBarDao;
import io.renren.api.entity.BtNavBarEntity;
import io.renren.api.service.BtNavBarService;
import io.renren.api.vo.LunBoVo;
import io.renren.api.vo.NavBarCVo;
import io.renren.common.utils.PageUtils;

import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import io.renren.utils.Query;
@Service("btNavBarService")
public class BtNavBarServiceImpl extends ServiceImpl<BtNavBarDao, BtNavBarEntity> implements BtNavBarService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Long pid = Long.parseLong((String) params.get("pid"));
        Page<BtNavBarEntity> page = this.selectPage(
                new Query<BtNavBarEntity>(params).getPage(),
                new EntityWrapper<BtNavBarEntity>()
                        .eq( "pid",pid)
        );

        return new PageUtils(page);
    }
    @Override
   public List<BtNavBarEntity> getAllNavBar(){
        return baseMapper.selectList(new EntityWrapper<BtNavBarEntity>().eq("pid",0L));
    }
    /**
     * 首页轮播
     */
    @Override
    public List<LunBoVo> getFirstLunBo(Long pid){
        List<BtNavBarEntity> orilost = this.selectList(new EntityWrapper<BtNavBarEntity>().eq("pid",pid));
        List<LunBoVo> backdata= new ArrayList<>();
        for (BtNavBarEntity or:orilost){
            LunBoVo tlbbean = new LunBoVo();
            tlbbean.setImg(or.getImg());
            tlbbean.setLink(or.getLink());
            tlbbean.setName(or.getName());
            backdata.add(tlbbean);
        }
        return backdata;
    }
}
